//Mark O'Meara - 1BA2 Assignment 2 - 08332240


import tcdIO.Terminal;

	class DatingAgencyProgram {
		
		public static void main(String[] args) {
	
	Terminal terminal1;		//This is the terminal used for entering all the details
	Terminal terminal2;		//This is the terminal used for returning the matches
	Person person1;
	Person person2;
	Person person3;
	Person person4;
	Person person5;
	Person person6;
		
		terminal1 = new Terminal("Personal details");		//new terminal to enter the details of all 6 people
		
		terminal1.println("Enter the details of all 6 individuals below. Please use lower case letters only.");
		terminal1.println("");
		terminal1.println("");
		
//Get details of all 6 individuals
		
	//Input for Person 1's details
		terminal1.println("Person 1:");
		person1 = new Person(terminal1.readString("Name: "),
				terminal1.readString("Gender (m/f): "),
				terminal1.readInt("Age: "),
				terminal1.readInt("Height (cm): "),
				terminal1.readString("Shift pattern (d/n): "),
				terminal1.readString("Smoker? (y/n): "),
				terminal1.readString("District: "));
		terminal1.println("");
		
		//while loop to ensure that only lower case letters were used in the various fields and that they were the right letters
		while ((!person1.getGender().equals("m") && !person1.getGender().equals("f")) || (person1.getAge() < 1 
				|| person1.getAge() > 121) ||(!person1.getShift().equals("d") && 
				!person1.getShift().equals("n")) || (!person1.getSmoke().equals("y") && !person1.getSmoke().equals("n"))){
			
			terminal1.println("Error! Please check what you have submitted and try again"); //this message will come up if there's an error
			terminal1.println("");
			terminal1.println("Person 1:");
			person1 = new Person(terminal1.readString("Name: "),
					terminal1.readString("Gender (m/f): "),
					terminal1.readInt("Age: "),
					terminal1.readInt("Height (cm): "),
					terminal1.readString("Shift pattern (d/n): "),
					terminal1.readString("Smoker? (y/n): "),
					terminal1.readString("District: "));
			terminal1.println("");
			
		}
		
	//Input for Person 2's details
		terminal1.println("Person 2:");
		person2 = new Person(terminal1.readString("Name: "),
				terminal1.readString("Gender (m/f): "),
				terminal1.readInt("Age: "),
				terminal1.readInt("Height (cm): "),
				terminal1.readString("Shift pattern (d/n): "),
				terminal1.readString("Smoker? (y/n): "),
				terminal1.readString("District: "));
		terminal1.println("");
		
		//while loop to ensure that only lower case letters were used in the various fields and that they were the right letters
		while ((!person2.getGender().equals("m") && !person2.getGender().equals("f")) ||(person2.getAge() < 1 
				|| person2.getAge() > 121) || (!person2.getShift().equals("d") && 
				!person2.getShift().equals("n")) || (!person2.getSmoke().equals("y") && !person2.getSmoke().equals("n"))){
			
			terminal1.println("Error! Please check what you have submitted and try again");
			terminal1.println("");
			terminal1.println("Person 2:");
			person2 = new Person(terminal1.readString("Name: "),
					terminal1.readString("Gender (m/f): "),
					terminal1.readInt("Age: "),
					terminal1.readInt("Height (cm): "),
					terminal1.readString("Shift pattern (d/n): "),
					terminal1.readString("Smoker? (y/n): "),
					terminal1.readString("District: "));
			terminal1.println("");
			
		}
		
		
	//Input for Person 3's details
		terminal1.println("Person 3:");
		person3 = new Person(terminal1.readString("Name: "),
				terminal1.readString("Gender (m/f): "),
				terminal1.readInt("Age: "),
				terminal1.readInt("Height (cm): "),
				terminal1.readString("Shift pattern (d/n): "),
				terminal1.readString("Smoker? (y/n): "),
				terminal1.readString("District: "));
		terminal1.println("");
		
		//while loop to ensure that only lower case letters were used in the various fields and that they were the right letters
		while ((!person3.getGender().equals("m") && !person3.getGender().equals("f")) || (person3.getAge() < 1 
				|| person3.getAge() > 121) || (!person3.getShift().equals("d") && 
				!person3.getShift().equals("n")) || (!person3.getSmoke().equals("y") && !person3.getSmoke().equals("n"))){
			
			terminal1.println("Error! Please check what you have submitted and try again");
			terminal1.println("");
			terminal1.println("Person 3:");
			person3 = new Person(terminal1.readString("Name: "),
					terminal1.readString("Gender (m/f): "),
					terminal1.readInt("Age: "),
					terminal1.readInt("Height (cm): "),
					terminal1.readString("Shift pattern (d/n): "),
					terminal1.readString("Smoker? (y/n): "),
					terminal1.readString("District: "));
			terminal1.println("");
			
		}
		
	//Input for Person 4's details
		terminal1.println("Person 4:");
		person4 = new Person(terminal1.readString("Name: "),
				terminal1.readString("Gender (m/f): "),
				terminal1.readInt("Age: "),
				terminal1.readInt("Height (cm): "),
				terminal1.readString("Shift pattern (d/n): "),
				terminal1.readString("Smoker? (y/n): "),
				terminal1.readString("District: "));
		terminal1.println("");
		
		//while loop to ensure that only lower case letters were used in the various fields and that they were the right letters
		while ((!person4.getGender().equals("m") && !person4.getGender().equals("f")) || (person4.getAge() < 1 
				|| person4.getAge() > 121) || (!person4.getShift().equals("d") && 
				!person4.getShift().equals("n")) || (!person4.getSmoke().equals("y") && !person4.getSmoke().equals("n"))){
			
			terminal1.println("Error! Please check what you have submitted and try again");
			terminal1.println("");
			terminal1.println("Person 4:");
			person4 = new Person(terminal1.readString("Name: "),
					terminal1.readString("Gender (m/f): "),
					terminal1.readInt("Age: "),
					terminal1.readInt("Height (cm): "),
					terminal1.readString("Shift pattern (d/n): "),
					terminal1.readString("Smoker? (y/n): "),
					terminal1.readString("District: "));
			terminal1.println("");
			
		}
		
	//Input for Person 5's details
		terminal1.println("Person 5:");
		person5 = new Person(terminal1.readString("Name: "),
				terminal1.readString("Gender (m/f): "),
				terminal1.readInt("Age: "),
				terminal1.readInt("Height (cm): "),
				terminal1.readString("Shift pattern (d/n): "),
				terminal1.readString("Smoker? (y/n): "),
				terminal1.readString("District: "));
		terminal1.println("");
		
		//while loop to ensure that only lower case letters were used in the various fields and that they were the right letters
		while ((!person5.getGender().equals("m") && !person5.getGender().equals("f")) ||(person5.getAge() < 1 
				|| person5.getAge() > 121) || (!person5.getShift().equals("d") && 
				!person5.getShift().equals("n")) || (!person5.getSmoke().equals("y") && !person5.getSmoke().equals("n"))){
			
			terminal1.println("Error! Please check what you have submitted and try again");
			terminal1.println("");
			terminal1.println("Person 5:");
			person5 = new Person(terminal1.readString("Name: "),
					terminal1.readString("Gender (m/f): "),
					terminal1.readInt("Age: "),
					terminal1.readInt("Height (cm): "),
					terminal1.readString("Shift pattern (d/n): "),
					terminal1.readString("Smoker? (y/n): "),
					terminal1.readString("District: "));
			terminal1.println("");
			
		}
		
	//Input for Person 6's details
		terminal1.println("Person 6:");
		person6 = new Person(terminal1.readString("Name: "),
				terminal1.readString("Gender (m/f): "),
				terminal1.readInt("Age: "),
				terminal1.readInt("Height (cm): "),
				terminal1.readString("Shift pattern (d/n): "),
				terminal1.readString("Smoker? (y/n): "),
				terminal1.readString("District: "));
		terminal1.println("");
		
		//while loop to ensure that only lower case letters were used in the various fields and that they were the right letters
		while ((!person6.getGender().equals("m") && !person6.getGender().equals("f")) || (person6.getAge() < 1 
				|| person6.getAge() > 121) || (!person6.getShift().equals("d") && 
				!person6.getShift().equals("n")) || (!person6.getSmoke().equals("y") && !person6.getSmoke().equals("n"))){
			
			terminal1.println("Error! Please check what you have submitted and try again");
			terminal1.println("");
			terminal1.println("Person 6:");
			person6 = new Person(terminal1.readString("Name: "),
					terminal1.readString("Gender (m/f): "),
					terminal1.readInt("Age: "),
					terminal1.readInt("Height (cm): "),
					terminal1.readString("Shift pattern (d/n): "),
					terminal1.readString("Smoker? (y/n): "),
					terminal1.readString("District: "));
			terminal1.println("");
			
		}
		
		
		terminal2 = new Terminal("Matches"); //New terminal for matches and non-matches
		
	//Use compare method to compare person 1 with person 2
	if (person1.matchWith(person2) == true) {
		terminal2.println(person1.getName() + " is a match for " + person2.getName());
	}
		
	//Use compare method to compare person 1 with person 3
	if (person1.matchWith(person3) == true) {
		terminal2.println(person1.getName() + " is a match for " + person3.getName());
	}
	
	//Use compare method to compare person 1 with person 4
	if (person1.matchWith(person4) == true) {
		terminal2.println(person1.getName() + " is a match for " + person4.getName());
	}
	
	//Use compare method to compare person 1 with person 5
	if (person1.matchWith(person5) == true) {
		terminal2.println(person1.getName() + " is a match for " + person5.getName());
	}
	
	//Use compare method to compare person 1 with person 6
	if (person1.matchWith(person6) == true) {
		terminal2.println(person1.getName() + " is a match for " + person6.getName());
	}
	
	//Use compare method to compare person 2 with person 3
	if (person2.matchWith(person3) == true) {
		terminal2.println(person2.getName() + " is a match for " + person3.getName());
	}
	
	//Use compare method to compare person 2 with person 4
	if (person2.matchWith(person4) == true) {
		terminal2.println(person2.getName() + " is a match for " + person4.getName());
	}
	
	//Use compare method to compare person 2 with person 5
	if (person2.matchWith(person5) == true) {
		terminal2.println(person2.getName() + " is a match for " + person5.getName());
	}
	
	//Use compare method to compare person 2 with person 6
	if (person2.matchWith(person6) == true) {
		terminal2.println(person2.getName() + " is a match for " + person6.getName());
	}
	
	//Use compare method to compare person 3 with person 4
	if (person3.matchWith(person4) == true) {
		terminal2.println(person3.getName() + " is a match for " + person4.getName());
	}
	
	//Use compare method to compare person 3 with person 5
	if (person3.matchWith(person5) == true) {
		terminal2.println(person3.getName() + " is a match for " + person5.getName());
	}
	
	//Use compare method to compare person 3 with person 6
	if (person3.matchWith(person6) == true) {
		terminal2.println(person3.getName() + " is a match for " + person6.getName());
	}
	
	//Use compare method to compare person 4 with person 5
	if (person4.matchWith(person5) == true) {
		terminal2.println(person4.getName() + " is a match for " + person5.getName());
	}
	
	//Use compare method to compare person 4 with person 6
	if (person4.matchWith(person6) == true) {
		terminal2.println(person4.getName() + " is a match for " + person6.getName());
	}
	
	//Use compare method to compare person 5 with person 6
	if (person5.matchWith(person6) == true) {
		terminal2.println(person5.getName() + " is a match for " + person6.getName());
	}
	
	}

}
